﻿using System.Collections.Generic;

using Microsoft.VisualStudio.Package;
using Microsoft.WowAddonStudio.Lua.LanguageService.Model;
using Microsoft.WowAddonStudio.Lua.Model;
using Microsoft.WowAddonStudio.Lua.Support;

namespace Microsoft.WowAddonStudio.Lua.LanguageService.Intellisense.Providers
{
    /// <summary>
    /// Provides static declarations for Lua keywords.
    /// </summary>
    public class KeywordDeclarationProvider : SimpleDeclarationProvider
    {
        private static readonly Declaration[] declarations = CreateKeywordDeclarations();

        private static Declaration[] CreateKeywordDeclarations()
        {
            return new[]
                   {
                       DeclarationFactory.CreateDeclaration<Keyword>("and"),
                       DeclarationFactory.CreateDeclaration<Keyword>("break"),
                       DeclarationFactory.CreateDeclaration<Keyword>("do"),
                       DeclarationFactory.CreateDeclaration<Keyword>("end"),
                       DeclarationFactory.CreateDeclaration<Keyword>("else"),
                       DeclarationFactory.CreateDeclaration<Keyword>("false"),
                       DeclarationFactory.CreateDeclaration<Keyword>("in"),
                       DeclarationFactory.CreateDeclaration<Keyword>("local"),
                       DeclarationFactory.CreateDeclaration<Keyword>("nil"),
                       DeclarationFactory.CreateDeclaration<Keyword>("not"),
                       DeclarationFactory.CreateDeclaration<Keyword>("or"),
                       DeclarationFactory.CreateDeclaration<Keyword>("repeat"),
                       DeclarationFactory.CreateDeclaration<Keyword>("return"),
                       DeclarationFactory.CreateDeclaration<Keyword>("self"),
                       DeclarationFactory.CreateDeclaration<Keyword>("then"),
                       DeclarationFactory.CreateDeclaration<Keyword>("this"),
                       DeclarationFactory.CreateDeclaration<Keyword>("true"),
                       DeclarationFactory.CreateDeclaration<Keyword>("until"),
                       DeclarationFactory.CreateDeclaration<Keyword>("while"),

                       // These declarations act as snippets as well
                       DeclarationFactory.CreateDeclaration<Keyword>("elseif"),
                       DeclarationFactory.CreateDeclaration<Keyword>("for"),
                       DeclarationFactory.CreateDeclaration<Keyword>("function"),
                       DeclarationFactory.CreateDeclaration<Keyword>("if"),
                   };
        }

        protected override IEnumerable<Declaration> GetSimpleDeclarations()
        {
            return declarations;
        }
    }
}